﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HR60_PanelSoft.Tools
{
    class LogUils
    {

        public static int DEBUG = 0;
        public static int INFO = 1;
        public static int ERROR = 2;

        public static int level = 0;//默认INFO级别
        public static void logger(int _level, string _tag, string _msg)
        {
            if (_level < level)
                return;


            string ret = "";
            if (_level == 0)
            {
                ret = ret + "DEBUG ";
            }
            else if (_level == 1)
            {
                ret = ret + "INFO ";
            }
            else if (_level == 2)
            {
                ret = ret + "ERROR ";
            }

            ret = ret + DateTime.Now +" ";

            ret = ret + " [" + _tag + "] :" + _msg;

            Console.WriteLine(ret);
        }


        public static void error(string _tag, Exception ex)
        {
            error(_tag, String.Format("Exception:\n{0}\n BaseException:\n{1} \n GetType:\n{2} \nMessage:\n{3}\n StackTrace:\n{4}", ex, ex.GetBaseException(), ex.GetType(), ex.Message, ex.StackTrace));
        }


      

        public static void debug( string _tag, string _msg)
        {

            logger(DEBUG, _tag, _msg);
        }



        public static void info(string _tag, string _msg)
        {
            logger(INFO, _tag, _msg);
        }

        public static void error(string _tag, string _msg)
        {
            logger(ERROR, _tag, _msg);
        }
        
    }
}
